#!/bin/sh

# Clean the trained model and intermediate output in hdfs
# use './clean.sh -e' to clean EBV and final results only
# use './clean.sh -a' to clean entire word_rank/ workspace
# use './clean.sh -w' to clean just the final results only

hadoop_home="/home/kelvin/hadoop"
hadoop="$hadoop_home/bin/hadoop"
hdfs="$hadoop dfs"
hdfs_pwd="word_rank"

if [ "$1" == "-a" ]; then
    $hdfs -rmr "$hdfs_pwd/"
elif [ "$1" == "-e" ]; then
    $hdfs -rmr "$hdfs_pwd/ebv_iteration_*/" \
               "$hdfs_pwd/word_rank/"
elif [ "$1" == "-w" ]; then
    $hdfs -rmr "$hdfs_pwd/word_rank/"
else
    $hdfs -rmr "$hdfs_pwd/mutual_infomation_model/" \
               "$hdfs_pwd/words_all/" \
               "$hdfs_pwd/words_filtered/" \
               "$hdfs_pwd/links_first/" \
               "$hdfs_pwd/links_second/" \
               "$hdfs_pwd/links_third/" \
               "$hdfs_pwd/links/" \
               "$hdfs_pwd/ebv_init_count/" \
               "$hdfs_pwd/ebv_iteration_*/" \
               "$hdfs_pwd/word_rank/"
fi
rm -f output/*
